package com.jmb.controller;

import com.jmb.po.AmountMessage;
import com.jmb.po.Place;
import com.jmb.service.RemoteFeignAdminService;
import com.jmb.vo.ResultData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: liuxaiorong
 * @ClassName AdminController
 * @Description: TODO
 * @create: 2022/07/01 16:06
 * @Version 1.0
 **/

@RestController
@Slf4j
@CrossOrigin
public class AdminController {



    @Autowired
    private RemoteFeignAdminService remoteFeignAdminService;

  /**
   * @Description:  查寻所有的接种点信息
   * @Param:
   * @return:  返回值Vo
   * @Author: liuxiaorong
   * @Date:
   */
    @GetMapping("/getAllPlace")
    public ResultData getAllPlace(){
        List<Place> listP=remoteFeignAdminService.getAllPlace();
        ResultData resultData= new ResultData("查询成功",listP,200);
        System.out.println(resultData);
        return resultData;
    }

    /**
     * @Description: 查询接种点的疫苗信息
     * @Param: pid
     * @return: ResultData
     * @Author: liuxiaorong
     * @Date:
     */
    @GetMapping("/getPlaceVs/{pid}")
    public ResultData getPlaceVs(@PathVariable("pid") Integer pid){
        List<AmountMessage> listAm=remoteFeignAdminService.getPlaceVs(pid);
        ResultData resultData= new ResultData("查询成功",listAm,200);
        System.out.println(resultData);
        return resultData;
    }

    /**
     * @Description: 修改投放点疫苗信息,只能修改数量
     * @Param:
     * @return:s
     * @Author: liuxiaorong
     * @Date:
     */
    @GetMapping("/updatePlaceVs/{mid}/{amount}")
    public ResultData updatePlaceVs(@PathVariable("mid") Integer mid,@PathVariable("amount") Integer amount){
        boolean b=remoteFeignAdminService.updatePlaceVs(mid,amount);
        ResultData resultData= new ResultData("修改成功",b,200);
        System.out.println(b);
        return resultData;
    }

}
